package Interface;

import Game.Dice;
import Game.TurnManager;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.Border;

public class EastPanel extends JPanel implements ActionListener
{

    TurnManager turnManager;
    DicePanel dicePanel;
    public EastPanel()
    {
        turnManager = turnManager.getTurnManager();
        Border whiteLine = BorderFactory.createLineBorder(Color.white,5);
        setBorder(whiteLine);
        setBackground(Color.darkGray);
        setSize(200,100);
        setLayout(new BorderLayout());

        add(getDicePanel(), BorderLayout.NORTH);


    }

    private JPanel getDicePanel()
    {
        dicePanel = new DicePanel();
        JPanel dicePanelContainer = new JPanel();
        dicePanelContainer.setLayout(new BorderLayout());
        dicePanelContainer.setBackground(Color.darkGray);

        JButton rollButton = new JButton("ROLL!");
        rollButton.setActionCommand("roll");
        rollButton.addActionListener(this);

        dicePanelContainer.add(dicePanel);
        dicePanelContainer.setBackground(Color.darkGray);
        dicePanelContainer.add(rollButton, BorderLayout.SOUTH);


        return dicePanelContainer;
    }
    public void actionPerformed(ActionEvent e) {
        String action = e.getActionCommand();

        if(action.equals("roll"))
        {
            turnManager.rollDice();
        }
    }

}